package com.swpu.zdl.controller;

import com.swpu.zdl.pojo.User;
import com.swpu.zdl.service.UserService;
import com.swpu.zdl.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
@CrossOrigin
public class UserController {
    @Autowired
    private UserService userService;
    @GetMapping("/login")
    public Result login(String username, String password){
        User user = userService.lambdaQuery().eq(User::getUsername, username).one();
        if (password.equals(user.getPassword())){
            return new Result(200, "登录成功", user);
        }
       else {
           return new Result(500, "登录失败");
        }
    }

}
